package cn.happy.favdish.model.database

import androidx.annotation.WorkerThread
import cn.happy.favdish.model.entities.FavDish
import kotlinx.coroutines.flow.Flow

/**
 * Author: created by ghappy on 2024/8/9 16:51
 *
 * Description:
 */
class FavDishRepository(private val favDishDao: FavDishDao) {
    @WorkerThread
    suspend fun insertFavDishData(favDish: FavDish){
        favDishDao.insertFavDishDetails(favDish)
    }

    val allDishesList: Flow<List<FavDish>> = favDishDao.getAllDishesList()


    @WorkerThread
    suspend fun updateFavDishData(favDish: FavDish){
        favDishDao.updateFavDishDetails(favDish)
    }

    val favoriteList: Flow<List<FavDish>> = favDishDao.getFavoriteDishesList()

    @WorkerThread
    suspend fun deleteFavDishData(favDish: FavDish){
        favDishDao.deleteFavDish(favDish)
    }

    fun filterListDishes(value: String): Flow<List<FavDish>> = favDishDao.getFilterDishesList(filterType =value)

}